/*
package com.dzl.admin;

import com.alibaba.fastjson.JSONObject;
import com.dzl.admin.pojo.SysAdmin;
import com.dzl.admin.pojo.query.SysAdminQuery;
import com.dzl.admin.pojo.vo.LoginSysAdminVo;
import com.dzl.admin.pojo.vo.MenuVo;
import com.dzl.admin.pojo.vo.SysAdminVo;
import com.dzl.admin.pojo.vo.SysMenuVo;
import com.dzl.admin.service.SysAdminService;
import com.dzl.admin.service.SysMenuService;
import com.dzl.base.controller.BaseController;
import com.dzl.config.ApplicationConfiguration;
import com.dzl.enterprise.pojo.WelfareEnterprise;
import com.dzl.enterprise.service.WelfareEnterpriseService;
import com.dzl.util.*;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.*;

*/
/**
 * Saas服务端用户表(SysAdmin)表控制层
 * @author caobucao
 * @since 2021-05-13 15:35:06
 *//*

@Slf4j
@RestController
@RequestMapping("sysAdmin")
public class SysAdminController extends BaseController {

    @Autowired
    private SysAdminService sysAdminService;
    @Autowired
    private SysMenuService sysMenuService;
    @Autowired
    private WelfareEnterpriseService welfareEnterpriseService;

    */
/**
     * Saas服务端登录验证
     * @date 2021/09/07 09:40
     * @author liuguanjun
     * @param query phone:用户名 password：密码
     * @return com.dzl.util.JsonResult
     *//*

    @PostMapping(value="/login")
    public JsonResult<String> login(HttpServletRequest request, @RequestBody JSONObject query) {
        String phone=query.getString("phone");
        String password=query.getString("password");
        if(EmptyUtils.isEmpty(phone)||EmptyUtils.isEmpty(password)) {
            return JsonResult.paramErrWithMsg("请输入用户名或密码");
        }
        //验证域名所属企业
        String servetName = request.getServerName();
        log.info("====================================saas服务端登录:sysAdmin/login?servetName="+servetName);
        String environment = ApplicationConfiguration.getPropertiesByKey("environment");
        if(environment.equals("dev")){//开发环境
            servetName = request.getServerName(); //测试服务器打开
//            servetName = "test-welfare-saas"; //测试阶段本地连测试库打开
        }else if(environment.equals("test")){//测试环境
            if(servetName.contains("test-")){
                servetName = servetName.split("\\.")[0];
            }
        }else if(environment.equals("prod")){//生产环境
            servetName = servetName.split("\\.")[0];
            //servetName.replaceAll("-saas","");
        }
        log.info("====================================saas服务端登录，解析之后的servetName="+servetName);
        WelfareEnterprise welfareEnterprise = welfareEnterpriseService.selectWelfareEnterpriseByDomain(servetName);
        if(EmptyUtils.isEmpty(welfareEnterprise)){
            return JsonResult.paramErrWithMsg("该企业未注册");
        }
        String token=sysAdminService.loginVerify(welfareEnterprise, phone, password);
        return JsonResult.success(token);
    }

    */
/**
     * 退出登录
     * @date 2021/5/14 17:15
     * @author caobucao
     * @param request
     * @return com.dzl.util.JsonResult<java.lang.Integer>
     *//*

    @GetMapping("/logout")
    public JsonResult<Integer> logout(HttpServletRequest request) {
        String token=request.getHeader("token");
        if(EmptyUtils.isEmpty(token)) {
            return JsonResult.fail();
        }
        RedisUtil.delete(token);
        return JsonResult.success();
    }

    */
/**
     * 获取登录用户详细信息
     * @date 2021/09/07 16:28
     * @author liuguanjun
     *//*

    @GetMapping("getLoginAdminInfo")
    public JsonResult<LoginSysAdminVo> getLoginAdminInfo_() {
        return JsonResult.success(getAdminInfo());
    }

    */
/**
     * 获取登录用户菜单信息
     * @date 2021/5/17 11:27
     * @author caobucao
     * @return JsonResult<List<Map<String, Object>>>
     *//*

    @GetMapping("getMenuList")
    public JsonResult<List<Map<String, Object>>> getMenuList() {
        List<MenuVo> list=sysMenuService.selectMenuListByRoleId(getAdminInfo());
        List<Map<String, Object>> result=new ArrayList<>();
        for(MenuVo vo:list) {
            Map<String, Object> map=new HashMap<>();
            if(EmptyUtils.isNotEmpty(vo.getName())) {
                map.put("name", vo.getName());
            }
            if(EmptyUtils.isNotEmpty(vo.getRedirect())) {
                map.put("redirect", vo.getRedirect());
            }
            if(EmptyUtils.isNotEmpty(vo.getAlwaysShow())) {
                map.put("alwaysShow", vo.getAlwaysShow());
            }
            map.put("children", vo.getChildren());
            map.put("component",vo.getComponent());
            map.put("meta", vo.getMeta());
            map.put("hidden", vo.getHidden());
            map.put("id", vo.getId());
            map.put("path", vo.getPath());
            result.add(map);
        }
        return new JsonResult<>(result,HttpCode.SUCCESS);
    }

    */
/**
     * 分页查询管理员管理列表数据
     * @date 2021/5/14 9:44
     * @author caobucao
     * @param query 查询条件
     * @return com.dzl.util.JsonResult
     *//*

    @GetMapping("/querySysAdminListPage")
    public PageUtils<SysAdminVo> querySysAdminListPage(SysAdminQuery query) {
        PageInfo<SysAdminVo> pageInfo = new PageInfo<>(sysAdminService.selectSysAdminListPage(query));
        return new PageUtils<>(pageInfo);
    }

    */
/**
     * 添加或修改管理员
     * @date 2021/5/13 17:46
     * @author caobucao
     * @param sysAdmin 管理员对象
     * @return com.dzl.util.JsonResult
     *//*

    @PostMapping("/saveAdmin")
    public JsonResult<Integer> saveAdmin(@RequestBody SysAdmin sysAdmin) {
        if(EmptyUtils.isEmpty(sysAdmin)) {
            return JsonResult.paramErr();
        }
        if(EmptyUtils.isEmpty(sysAdmin.getUserName())) {
            return JsonResult.paramErrWithMsg("请输入管理员姓名");
        }
        if(EmptyUtils.isEmpty(sysAdmin.getRoleId())) {
            return JsonResult.paramErrWithMsg("请选择关联角色");
        }
        if(EmptyUtils.isEmpty(""+sysAdmin.getUserStatus())) {
            return JsonResult.paramErrWithMsg("请选择用户状态");
        }
        if(EmptyUtils.isEmpty(sysAdmin.getPhone())) {
            return JsonResult.paramErrWithMsg("请输入账号");
        }
        if(EmptyUtils.isEmpty(sysAdmin.getPassword())) {
            return JsonResult.paramErrWithMsg("请输入登录密码");
        }
        Integer loginUserId = getAdminInfo().getId();
        sysAdmin.setUserStatus(1);
        if(EmptyUtils.isEmpty(sysAdmin.getId())) {
            sysAdmin.setUpdater(loginUserId);
            sysAdmin.setCreater(loginUserId);
        } else {
            if(sysAdmin.getId() == 1) {
                return JsonResult.paramErrWithMsg("不允许修改本账号信息");
            }
            sysAdmin.setUpdateTime(new Date());
            sysAdmin.setUpdater(loginUserId);
        }
        return JsonResult.success(sysAdminService.saveAdmin(sysAdmin));
    }

    */
/**
     * 更改用户状态，冻结或解冻
     * @date 2021/5/20 16:25
     * @author caobucao
     * @param query  传入json
     * @return com.dzl.util.JsonResult
     *//*

    @PostMapping("/updateUserStatus")
    public JsonResult updateUserStatus(@RequestBody JSONObject query) {
        Integer id=query.getInteger("id");
        Integer userStatus=query.getInteger("userStatus");
        SysAdmin sysAdmin = new SysAdmin();
        sysAdmin.setId(id);
        sysAdmin.setUserStatus(userStatus);
        sysAdmin.setUpdater(getAdminInfo().getId());
        return JsonResult.success(sysAdminService.updateUserStatus(sysAdmin));
    }

    */
/**
     * 删除管理员用户
     * @date 2021/5/13 19:17
     * @author caobucao
     * @param id 用户id
     * @return com.dzl.util.JsonResult
     *//*

    @DeleteMapping("/deleteSysAdmin")
    public JsonResult deleteSysAdmin(Integer id) {
        SysAdmin sysAdmin = new SysAdmin();
        sysAdmin.setId(id);
        sysAdmin.setStatus(0); //0删除
        sysAdmin.setUpdater(getAdminInfo().getId());
        return JsonResult.success(sysAdminService.updateUserStatus(sysAdmin));
    }

    */
/**
     * 获取登录用户的权限树，只显示已拥有的权限，没有的直接不显示
     * @date 2021/5/25 15:56
     * @author caobucao
     * @param
     * @return com.dzl.util.JsonResult<java.util.List<java.util.Map<java.lang.String,java.lang.Object>>>
     *//*

    @GetMapping("getMenuAndPermissionForLoginUser")
    public JsonResult<List<Map<String, Object>>> getMenuAndPermissionForLoginUser() {
        Integer roleId = getAdminInfo().getRoleId();
        return JsonResult.success(sysAdminService.getMenuAndPermissionByRoleIdOnlyHave(roleId));
    }

    */
/**
     * 获取所有菜单权限树
     * @date 2021/5/21 15:30
     * @author caobucao
     * @param
     * @return com.dzl.util.JsonResult<java.util.List<java.util.Map<java.lang.String,java.lang.Object>>>
     *//*

    @GetMapping("getMenuAndPermission")
    public JsonResult<List<Map<String, Object>>> getMenuAndPermission() {
        return JsonResult.success(sysAdminService.getMenuAndPermissionByRoleIdOnlyHave(getAdminInfo().getRoleId()));
    }

    */
/**
     * 获取角色菜单权限树-回显用，显示所有，勾选角色已拥有
     * @date 2021/5/21 15:30
     * @author caobucao
     * @param roleId 角色id
     * @return com.dzl.util.JsonResult<java.util.List<java.util.Map<java.lang.String,java.lang.Object>>>
     *//*

    @GetMapping("getMenuAndPermissionByRoleId")
    public JsonResult<List<Map<String, Object>>> getMenuAndPermissionByRoleId(Integer roleId) {
        return JsonResult.success(sysAdminService.getMenuAndPermissionByRoleId(roleId));
    }

    */
/**
     * 更改登录用户的密码
     * @date 2021/9/8 9:56
     * @author caobucao
     * @param obj 两次输入的新密码
     * @return com.dzl.util.JsonResult<java.lang.Integer>
     *//*

    @PostMapping("/updateAdminPassword")
    public JsonResult<Integer> updateAdminPassword(@RequestBody JSONObject obj) {
        String firstPwd = obj.getString("firstPwd");
        String secondPwd = obj.getString("secondPwd");
        //判断原密码是否正确
        String oldPwd = PasswordUtil.AESDecrypt(getAdminInfo().getPassword());
        if(!firstPwd.equals(oldPwd)) {
            return JsonResult.paramErrWithMsg("原密码输入错误！");
        }
        String password = PasswordUtil.AESEncrypt(secondPwd);
        Integer id = getAdminInfo().getId();
        SysAdmin sysAdmin = new SysAdmin();
        sysAdmin.setId(id);
        sysAdmin.setPassword(password);
        return JsonResult.success(sysAdminService.updateByPrimaryKeySelective(sysAdmin));
    }


    */
/**
     * 描述:根据角色获取菜单树
     * @date 2021/5/12 16:28
     * @author wangchao
     * @Param
     * @return com.dzl.util.JsonResult<java.util.List<com.dzl.menu.pojo.vo.MenuVo>>
     **//*

    @ApiOperation(value = "根据角色获取菜单树", notes = "根据角色获取菜单树")
    @GetMapping("/queryByRoleIdMenuTree")
    public JsonResult<List<SysMenuVo>> queryByRoleIdMenuTree(){
        return JsonResult.success(null);
    }
}
*/
